#! /bin/sh

stamp=`/bin/date +'%Y-%m-%d %H:%M:%S'`
script=`basename $0`
LOGFILE=/tmp/pam-script.log
echo ============= >> $LOGFILE
echo $stamp $script $PAM_SERVICE $PAM_TYPE                              \
        user=$PAM_USER ruser=$PAM_RUSER rhost=$PAM_RHOST                \
        tty=$PAM_TTY                                                    \
        args=["$@"]                                                     \
        >> $LOGFILE

echo check $PAM_USER >> $LOGFILE

#if [[ "x$PAM_AUTHTOK" == "123456" ]]; then
#       exit 0
#fi
#exit 1

python3 /root/check_totp.py $PAM_USER $PAM_AUTHTOK >> $LOGFILE
exit $?
